<template>
  <div class="collect-page">
    <van-nav-bar title="我的收藏" fixed />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
    <ArticleItem v-for="item in list" :key="item.id" :item='item'></ArticleItem>
    </van-list>
  </div>
</template>

<script>
import { getCollectsOrLike } from '@/api/article'
export default {
  name: 'collect-page',
  data () {
    return {
      list: [],
      loading: false,
      finished: false,
      page: 1

    }
  },
  methods: {
    async onLoad () {
      const res = await getCollectsOrLike({
        page: this.page,
        pageSize: 10,
        optType: 2
      })
      this.page++
      this.list = [...this.list, ...res.data.data.rows]
      this.loading = false
      if (this.page > res.data.data.pageTotal) {
        this.finished = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
